﻿using System;
using System.Web.Mvc;
using Autofac;
using Autofac.Integration.Mvc;
using Hangfire;
using Microsoft.Owin;
using Owin;
using WSPay.Application;
using WSPay.Common;
using WSPay.Common.Data;
using WSPay.Common.Log;
using WSPay.EF;

[assembly: OwinStartupAttribute(typeof(WSPay.Web.Startup))]
namespace WSPay.Web
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var builder = new ContainerBuilder();

            builder.Register(x => new UnitOfWork(new DB())).As<IUnitOfWork>();
            builder.RegisterType<WSBService>().As<IWSBService>();
            builder.RegisterType<PaymentService>().As<IPaymentService>();
            builder.RegisterType<PaymentService>().As<PaymentService>();
            builder.RegisterType<RefoundService>().As<IRefoundService>();
            builder.RegisterType<ClientService>().As<IClientService>();
            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            var container = builder.Build();         
            GlobalConfiguration.Configuration.UseAutofacActivator(container);
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");
            app.UseHangfireServer();
            app.UseHangfireDashboard("/job");
            ConfigureAuth(app);
          
          
        }
        public void InitDefaultData()
        {
           
        }
      
    }
}
